<?php

namespace Models;

use Classes\BaseModel;


class Project_Model extends \Classes\BaseModel
{
    private $name;
    private $description;


    public function Read($projectId)
    {
        // Extract results into the array $users (and evaluate if there are any results at the same time)..
        if ( $projects = $this->db->get_results("SELECT name, email FROM Projects WHERE id = {$projectId}") )
        {
            //TODO: Throw exception if the result set returns more than one project, indicates that auto increment is off on the table.
            // Loop through the results.
            foreach ( $projects as $project )
            {
                $this->_id = $project->id;
                $this->name = $project->name;
                $this->description = $project->description;
            }
        }
        else
        {
            //todo: Throw exception if the project is not found by reference ID.
        }
    }

    public function Update()
    {

    }

    public function Delete($id)
    {
        $this->db->query("DELETE FROM Projects WHERE id={$id}");
    }

    //Getters & Setters Below...

    public function setName($name)
    {
        $this->name = $name;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setDescription($description)
    {
        $this->description = $description;
    }

    public function getDescription()
    {
        return $this->description;
    }

    public function getId()
    {
        return $this->_id;
    }
}
